import type { LoginResult, LoginWxMinParams, Result } from '@/types/member'
import { http } from '@/utils/http'

/**
 * 手机号模拟登录
 * @param phone
 */
export const phoneMocksLogin = async (phone: string) => {
  return await http<Result>({
    url: '/mobile/auth/phoneMocksLogin',
    method: 'POST',
    data: {
      phone,
    },
  })
}

/**
 * 微信登录
 * @param data
 */
export const wechatLogin = async (data: LoginWxMinParams) => {
  return await http<LoginResult>({
    url: '/mobile/auth/wechatLogin',
    method: 'POST',
    data,
  })
}

/**
 * 账号密码登录
 * @param data
 */
export const accountAndPasswordLogin = async (data: { login: string; password: string }) => {
  return await http<Result>({
    url: '/mobile/auth/accountAndPasswordLogin',
    method: 'POST',
    data,
  })
}

/**
 * 获取个人信息
 */
export const getUserInfo = async (id: string) => {
  return await http<Result>({
    method: 'GET',
    url: '/system/users/details',
    data: {
      id,
    },
  })
}
